Racial discrimination continues to be pervasive in cultures throughout the world. Researchers examined the level of racial discrimination in the United States labor market by randomly assigning identical résumés black-sounding or white-sounding names and observing the impact on requests for interviews from employers.
In the dataset provided, each row represents a resume. The 'race' column has two values, 'b' and 'w', indicating black-sounding and white-sounding. The column 'call' has two values, 1 and 0, indicating whether the resume received a call from employers or not.
Note that the 'b' and 'w' values in race are assigned randomly to the resumes.
You will perform a statistical analysis to establish whether race has a significant impact on the rate of callbacks for resumes.
Answer the following questions in this notebook below and submit to your Github account.
You can include written notes in notebook cells using Markdown:
In [3]:
import pandas as pd
import numpy as np
from scipy import stats
In [4]:
data = pd.io.stata.read_stata('data/us_job_market_discrimination.dta')
In [5]:
# number of callbacks for balck-sounding names
sum(data[data.race=='b'].call)
Out[5]:
In [6]:
data.head()
Out[6]:
In [17]:
# Retrieve raca and call data.
race_call = data[['race','call']]
race_call_black = race_call[race_call.race=='b']
race_call_white = race_call[race_call.race=='w']
In [18]:
len(race_call_black),len(race_call_white)
Out[18]:
Ans:- It is binomial distribution.
p_w = probability of success of white person. p_b = probability of success of black person.
In [19]:
p_b = len(race_call_black[race_call_black.call==1])/len(race_call_black)
p_b
Out[19]:
In [20]:
p_w= len(race_call_white[race_call_white.call==1])/len(race_call_white)
p_w
Out[20]:
In [21]:
print(len(race_call_white)*p_w)
print(len(race_call_white)*(1-p_w))
print(len(race_call_black)*p_b)
print(len(race_call_black)*(1-p_b))
Above conditions are satisfied so CLT is applicable.
=======================================================================================================================
Null Hypothesis: there is no racial discrimination. (p_b = p_w) Alternate Hypothesis : There is. (p_b != p_w)
=======================================================================================================================
Assume 95% confidence interval. So the critical value = 1.96.
Margin of Error =
In [23]:
import math
z = 1.96
margin_of_error = z*math.sqrt(p_w*(1-p_w)/len(race_call_white)+p_b*(1-p_b)/len(race_call_black))
margin_of_error
Out[23]:
The confidence interval is: p1 − p2 ± (margin of error)
In [24]:
[p_w - p_b - z * margin_of_error,
p_w - p_b + z * margin_of_error]
Out[24]:
In [29]:
from statsmodels.stats.proportion import proportions_ztest as pz
white_call = len(race_call_white[race_call_white.call==1])
black_call = len(race_call_black[race_call_black.call==1])
zstat,p_value = pz(np.array([white_call,black_call]),np.array([len(race_call_white),len(race_call_black)]),value=0)
if p_value < 0.05:
print ("Null Hypotesis Rejected.\nThere is racial discrimination")
=======================================================================================================================
Since the null hypothesis is rejected due to the small p-value, race does have an impact on the rate at which applicants are accepted for interviews by employers.
In [ ]:
In [ ]:
In [ ]:
In [ ]: